﻿
<%@ Page Language="C#" AutoEventWireup="true" MasterPageFile="~/BodyMasterPage.Master"
    CodeBehind="wfConfHoraMnt.aspx.cs" Inherits="RH.wfConfHoraMnt" %>

<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="ajax" %>
<%@ Import Namespace="Texfina.Common.Mg" %>
<%@ Import Namespace="Texfina.Core.Common" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="Server">
    <link href="../Styles/jquery-ui.custom.css" rel="stylesheet" type="text/css" />
    <script type="text/javascript">
        window.onload = function () {
            var menuTable = document.getElementById('<%=mnuToolbar.ClientID %>');
            var menuLinks = menuTable.getElementsByTagName("a");
            if (menuLinks != null) {
                switch (menuLinks.length) {
                    case 1:
                        menuLinks[0].onclick = function () { return validateEditForm('_BTTSAVE') }
                        break;
                        
                }
            }

            this.ResizeGrid();
            this.MessageOnPostback();
        }
          
        function ResizeGrid() {
            internalGridResize("<%= grdList.ClientID %>");
        }

        function GetValueFile() {
            document.getElementById('<%=txtDocExcel.ClientID %>').value = document.getElementById('<%=fuDocExcel.ClientID %>').value;
        }

        function RadioCheck(rb) {
            var gv = document.getElementById("<%=grdList.ClientID%>");
            var rbs = gv.getElementsByTagName("input");
            var sel = gv.getElementsByTagName("select");
            var row = rb.parentNode.parentNode;
            
            for (var i = 0; i < rbs.length; i++) {
                if (rbs[i].type == "radio") {
                    if (rbs[i] == rb) {
                        sel[i].value = "";
                    }
                    if (rbs[i].checked && rbs[i] != rb) {
                        rbs[i].checked = false;
                    }
                }
            }
        }

        function ddlidHoraValidate(objddl) {
            var gv = document.getElementById("<%=grdList.ClientID%>");
            var ddl = gv.getElementsByTagName("select");
            var rbs = gv.getElementsByTagName("input");
            var row = objddl.parentNode.parentNode;
            var flag = 0;
            for (var i = 0; i < ddl.length; i++) {
                if (ddl[i].type == "select-one") {
                    if (ddl[i].value == objddl.value && objddl.value != "") {
                        flag++;
                    }
                }
            }
            if (flag > 1) {
                objddl.value = "";
               AtentionAlert("La Hora seleccionada es utilizada por otro campo.");
               
            }
            rbs[row.rowIndex-1].checked = false;
        }
    </script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">
    <div class="ToolBar">
        <asp:Menu ID="mnuToolbar" runat="server" Orientation="Horizontal" CssClass="ToolBarControl"
            OnMenuItemClick="mnuToolbar_MenuItemClick">
            <Items>
                <asp:MenuItem Text="Guardar" Value="_BTTSAVE" ImageUrl="../Images/Icons/Enabled/SAVE.png">
                </asp:MenuItem>
            </Items>
        </asp:Menu>
    </div>
    <div class="DataHeader">
        <table id="TableDataHeader" cellpadding="0" cellspacing="0">
            <tr>
                <td colspan="3">
                    &nbsp;
                </td>
            </tr>
            <tr>
                <td style="width: 5px">
                    &nbsp;
                </td>
                <td>
                    <div style="border: 1px solid #ccc; border-radius: 5px; -moz-border-radius: 5px;
                        -webkit-border-radius: 5px; -ms-border-radius: 5px;">
                        <table width="100%" cellpadding="0" cellspacing="2">
                            <tr>
                                <td colspan="13">
                                    &nbsp;
                                </td>
                            </tr>
                            <tr>
                                <td style="width: 5px;">
                                    &nbsp;
                                </td>
                                <td style="width:60px;">
                                    Formato Excel
                                </td>
                                <td style="width:200px;">
                                    <esd:esdTextBox ID="txtDocExcel" runat="server" Width="200px"></esd:esdTextBox>
                                </td>
                                <td>
                                    <div class="esdDivUploadFile">
                                        <asp:FileUpload ID="fuDocExcel" onchange="GetValueFile();" runat="server" CssClass="esdUploadFile" Width="280px" accept="xls|xlsx" />
                                        Examinar
                                    </div>
                                </td>
                                <td style="width: 30px;">
                                    &nbsp;
                                </td>
                                <td>
                                    <esd:esdButton ID="btnDocExcel" runat="server" Text="Obtener Campos" OnClick="btnDocExcel_Click" />
                                </td> 
                                <td colspan="6">
                                    &nbsp;
                                </td>   
                                <td style="width: 5px;">
                                    &nbsp;
                                </td>
                            </tr>
                            <tr>
                                <td colspan="13">
                                    &nbsp;
                                </td>
                            </tr>
                        </table> 
                     </div>
                </td> 
                <td style="width: 5px">
                    &nbsp;
                </td>
            </tr> 
            <tr>
                <td colspan="3">
                    &nbsp;
                </td>
            </tr>
        </table> 
    </div>
    <div class="DataDetail">
        <table width="100%" cellpadding="0" cellspacing="0">
            <tr>
                <td style="width: 5px;">
                    &nbsp;
                </td>
                <td>
                    <esd:esdGridView CssClass="esdGridView" ID="grdList" runat="server" ScrollWidth="100%"
                        Width="100%" ShowHeaderWhenEmpty="True" AutoGenerateColumns="False" DataKeyNames="idHoraExcel"
                        OnRowDataBound="grdList_RowDataBound" RowStyle-Height="22px">
                        <Columns>
                            <asp:BoundField DataField="idHoraExcel" HeaderText="Posicion"></asp:BoundField>
                            <asp:BoundField DataField="dsHoraExcel" HeaderText="Campo Excel"></asp:BoundField>
                            <asp:BoundField DataField="idHora" HeaderStyle-CssClass="hideDataGridColumn" 
                            ItemStyle-CssClass="hideDataGridColumn">
                            </asp:BoundField>
                            <asp:TemplateField HeaderText="Codigo de Personal" ItemStyle-HorizontalAlign="Center">
                                <ItemTemplate>
                                    <asp:RadioButton ID="rdbidPersonal" runat="server" onclick="RadioCheck(this);"/>
                                </ItemTemplate>
                            </asp:TemplateField>
                            <asp:TemplateField HeaderText="Hora" ItemStyle-HorizontalAlign="Center">
                                <ItemTemplate>
                                    <asp:DropDownList ID="ddlidHora" runat="server" Width="250px" onChange="ddlidHoraValidate(this);">
                                    </asp:DropDownList>
                                </ItemTemplate>
                            </asp:TemplateField>
                            <asp:BoundField DataField="stIdPersonal" HeaderStyle-CssClass="hideDataGridColumn" 
                            ItemStyle-CssClass="hideDataGridColumn">
                            </asp:BoundField>
                            <asp:BoundField DataField="stAnulado" HeaderStyle-CssClass="hideDataGridColumn" 
                            ItemStyle-CssClass="hideDataGridColumn">
                            </asp:BoundField>
                        </Columns>
                        <EmptyDataTemplate>
                            <div id="gridempty">
                                <asp:Image ID="imgEmpty" runat="server" ImageUrl="../Images/Controls/Attention.png" />
                                &nbsp;No existen registros para esta solicitud.
                            </div>
                        </EmptyDataTemplate>
                    </esd:esdGridView>
                </td>
                <td style="width: 5px;">
                    &nbsp;
                </td>
            </tr>
        </table>
    </div>
    <asp:HiddenField ID="hdnMsgOPB" runat="server" />
</asp:Content>
